package model

type CreateEventRequest struct {
	Name         string `json:"name" validate:"required,min=1,max=64"`
	ResourceType string `json:"resource_type" validate:"oneof=user fleet build instance process session request"`
	TraceService string `json:"trace_service" validate:"oneof=fleetmanager appgateway aass auxproxy"`
	ResourceId   string `json:"resource_id" validate:"min=0,max=64"`
	ResourceName string `json:"resource_name" validate:"min=0,max=64"`
	TraceState   string `json:"trace_state" validate:"oneof=NORMAL WARNING INCIDENT"`
	EventType    string `json:"event_type" validate:"oneof=data manager"`
	SourceIp     string `json:"source_ip" validate:"ip"`
	Details      string `json:"details"`
	SmnMessage   string `json:"message" validate:"min=0,max=490"`
}

type ListEventsResponse struct {
	TotalCount int                 `json:"total_count"`
	Count      int                 `json:"count"`
	Events     []ShowEventResponse `json:"events"`
}

type ShowEventResponse struct {
	Id           string `json:"id"`
	Name         string `json:"name"`
	ResourceType string `json:"resource_type"`
	TraceService string `json:"trace_service"`
	ResourceId   string `json:"resource_id"`
	ResourceName string `json:"resource_name"`
	TraceState   string `json:"trace_state"`
	EventType    string `json:"event_type"`
	SourceIp     string `json:"source_ip"`
	Details      string `json:"details"`
	SmnMessage   string `json:"message"`
	NoticeState  string `json:"notice_state"`
	RecordTime   string `json:"record_time"`
}

type ShowMessageResponse struct {
	Name                string        `json:"name"`
	TopicUrn            string        `json:"topic_urn"`
	DisplayName         string        `json:"display_name"`
	EnterpriseProjectId string        `json:"enterprise_project_id"`
	SubscriptionCount   int           `json:"subscription_count"`
	Subscriptions       []Subcription `json:"subcriptions"`
	StateAndReason      string        `json:"state_and_reason"`
	NoticeTraceStatus   []string      `json:"notice_trace_status"`
	CreationTime        string        `json:"creation_time"`
}

type Subcription struct {
	Protocol       string `json:"protocol"`
	Endpoint       string `json:"endpoint"`
	SubcriptionUrn string `json:"subcription_urn"`
	Remark         string `json:"remark"`
	Status         int    `json:"status"`
}

type AddSubscriptionRequest struct {
	Protocol string `json:"protocol" validate:"oneof=email sms"`
	Endpoint string `json:"endpoint"`
	Remark   string `json:"remark"`
}

type CreateTopicRequest struct {
	Name                string   `json:"name" validate:"required,min=1,max=255"`
	DisplayName         string   `json:"display_name" validate:"min=0,max=192"`
	EnterpriseProjectId string   `json:"enterprise_project_id" validate:"min=0,max=64"`
	NoticeTraceStatus   []string `json:"notice_trace_status" validate:"stringListNotDelicated,dive,oneof=NORMAL WARNING INCIDENT"`
}

type UpdateTopicRequest struct {
	NoticeTraceStatus []string `json:"notice_trace_status" validate:"required,stringListNotDelicated,dive,oneof=NORMAL WARNING INCIDENT"`
}

type QueryEventsParam struct {
	TraceId      string `json:"trace_id" validate:"omitempty"`
	ResourceType string `json:"resource_type" validate:"omitempty,oneof=user fleet instance process session build request"`
	TraceState   string `json:"trace_state" validate:"omitempty,oneof=NORMAL WARNING INCIDENT"`
	StartTime    string `json:"start_time" validate:"omitempty,checkTimeFormat"`
	EndTime      string `json:"end_time" validate:"omitempty,checkTimeFormat"`
	EventType    string `json:"event_type" validate:"omitempty,oneof=data manager"`
}
